package us.esme.managers
{
	import com.asfusion.mate.events.Dispatcher;
	
	import us.esme.events.NotificationEvent;
	
	
	public class MessageManager{

		[Bindable] public var messages:XMLList;
		
		public function MessageManager(){
			messages = new XMLList();
		}
		
		public function storeMessages(obj:XML):void{
		   
		   var newMessages:XMLList = obj..message as XMLList
		   var numberofmessages:Number = newMessages.length() 
		   messages = newMessages + messages;
		   
		   if(numberofmessages > 0){
			   var notificationEvent:NotificationEvent = new NotificationEvent(NotificationEvent.NOTIFY);
			   notificationEvent.number_of_messages = numberofmessages.toString();
			   notificationEvent.message = "New Messages"
			   new Dispatcher().dispatchEvent(notificationEvent);
		   }
		   
		}
	
	}
}